<?php

/**
 * class which has function for all the validation of user input in the application
 *
 * @author Abdullah
 */

/**
 * 
 */
class User {

    private $userName;
    private $userPassword;
    private $userEmail;
    private $userPostcode;
    private $validDetails = array(
        'userName' => false, 'userPassword' => false, 'userEmail' => false, 'userPostcode' => false
    );

    public function __construct() {
        ;
    }

    public function validateAccUserSetup($strValid, $userName) {
        // validate input from the form
        if (preg_match('/[^a-zA-Z ]|^$/', $userName) | strlen($userName) > 11)
            $strValid .= "  Username<br />\n";
        return $strValid;
    }

    public function validateAccPostcodeSetup($strValid, $userPassword) {
        if (preg_match('/^[a-zA-Z][a-zA-Z0-9]{1,3}[0-9][a-zA-z][a-zA-z]$/', $userPostcode))
            $strValid .= "  uk postcode<br />\n";
        return $strValid;
    }

    public function validateAccEmailSetup($strValid, $userEmail) {
        if (!preg_match('/^([\w\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/', $userEmail))
            $strValid .= "  Email<br />\n";
        return $strValid;
    }

    public function validateAccPasswdSetup($strValid, $userPassword) {
        if (preg_match('/^[a-z0-9_-]{6,18}$/', $userPassword))//net tuts : Vasili
            $strValid .= "  password<br />\n";
        return $strValid;
    }

}


/**
 * this is a function to validate the validation code format
 * 
 */

?>
